package com.wqr.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.wqr.dao.DeliciousDao;
import com.wqr.pojo.Delicious;
import com.wqr.pojo.DeliciousExample;

@Service
public class DeliciousServiceImp implements DeliciousService {

	@Autowired
	public DeliciousDao deliciousDao;
	
	public List<Delicious> list(Delicious delicious) throws Exception {
		//DeliciousExample example = new DeliciousExample();
		List<Delicious> list = deliciousDao.selectByWhere(delicious);
		return list;
	}

	public int delectDelicious(Integer userStateId) throws Exception {
		int a = deliciousDao.deleteByPrimaryKey(userStateId);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}
	public int insertDelicious(Delicious delicious) throws Exception {
		int a = deliciousDao.insertSelective(delicious);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}
	public int updateDelicious(Delicious delicious) throws Exception {
		int a = deliciousDao.updateByPrimaryKeySelective(delicious);
		if(a > 0) {
			return 1;
		}else {
			return 0;
		}
	}

	public List<Delicious> selectDelicious(Delicious delicious) throws Exception {
		List<Delicious> list = deliciousDao.selectByWhere(delicious);
		return list;
	}

	public List<Delicious> selectByPrimaryKey(Integer deliciousId) throws Exception {
		List<Delicious> list = deliciousDao.selectByPrimaryKey(deliciousId);
		return list;
	}

	public int selectDeliciousId() throws Exception {
		int a = deliciousDao.selectDeliciousId();
		return a;
	}

	public List<Delicious> selectByUser(Delicious delicious) throws Exception {
		List<Delicious> list = deliciousDao.selectByUser(delicious);
		return list;
	}

	public List<Delicious> list() throws Exception {
		DeliciousExample example = new DeliciousExample();
		List<Delicious> list = deliciousDao.selectByExample(example);
		return list;
	}

}
